package com.mvc.security.model;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorType;
import javax.persistence.Entity;
import javax.persistence.Transient;
import javax.validation.constraints.NotNull;

import org.hibernate.validator.constraints.Length;

import com.mvc.framework.model.CommonAuditableEntity;

@Entity(name = "F_USER")
@DiscriminatorColumn(name = "DATA_TYPE", discriminatorType = DiscriminatorType.INTEGER)
public class User extends CommonAuditableEntity {
	private static final int MAX_NAME_LENGTH = 64;
	
	public static final int USER_TYPE_COMMON = 1;
	
	public static final int USER_TYPE_MEMBER = 2;
	
	public static final int USER_TYPE_VIP = 3;
	
	public static final int USER_TYPE_GROUP = 4;

	public static final int USER_TYPE_SYSTEM_ADMIN = 1;
	public static final int USER_TYPE_SERVER_ADMIN = 2;
	public static final int USER_TYPE_PRODUCT_MANAGER = 3;

	@Length(max = MAX_NAME_LENGTH)
	@NotNull
	private String loginName;
	@Length(max = MAX_NAME_LENGTH)
	@NotNull
	private String userName;
	private String password;
	private Integer type;
	private String phone;
	private String mobilePhone;
	private String address;
	@NotNull
	private String email;
	private Integer birthday;
	private String city;
	private Integer sex;
	private String remark;
	private Integer departmentId;
	@Transient
	private Department department;
	@Transient
	private List<Menu> menus = new ArrayList<Menu>();
	@Transient
	private List<Operation> operations = new ArrayList<Operation>();
	@Transient
	private List<DimLocation> dimLocations = new ArrayList<DimLocation>();
	@Transient
	private List<Role> roles = new ArrayList<Role>();
	@Transient
	private String fullName;

	@Transient
	public Department getDepartment() {
		return department;
	}

	public void setDepartment(Department department) {
		this.department = department;
	}

	@Transient
	public List<Menu> getMenus() {
		return menus;
	}

	public void setMenus(List<Menu> menus) {
		this.menus = menus;
	}

	@Transient
	public List<Operation> getOperations() {
		return operations;
	}

	public void setOperations(List<Operation> operations) {
		this.operations = operations;
	}

	@Transient
	public List<Role> getRoles() {
		return roles;
	}

	public void setRoles(List<Role> roles) {
		this.roles = roles;
	}

	@Column(nullable = false, name = "LOGIN_NAME")
	public String getLoginName() {
		return loginName;
	}

	public void setLoginName(String loginName) {
		this.loginName = loginName;
	}

	@Column(nullable = false, name = "USER_NAME")
	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public Integer getType() {
		return type;
	}

	public void setType(Integer type) {
		this.type = type;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getAddress() {
		return address;
	}

	@Column(name = "MOBILE_PHONE")
	public String getMobilePhone() {
		return mobilePhone;
	}

	public void setMobilePhone(String mobilePhone) {
		this.mobilePhone = mobilePhone;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public Integer getBirthday() {
		return birthday;
	}

	public void setBirthday(Integer birthday) {
		this.birthday = birthday;
	}

	public String getCity() {
		return city;
	}

	public void setCity(String city) {
		this.city = city;
	}

	public Integer getSex() {
		return sex;
	}

	public void setSex(Integer sex) {
		this.sex = sex;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	@Transient
	public String getFullName() {
		return fullName;
	}

	public void setFullName(String fullName) {
		this.fullName = fullName;
	}

	public Integer getDepartmentId() {
		return departmentId;
	}

	public void setDepartmentId(Integer departmentId) {
		this.departmentId = departmentId;
	}

	@Transient
	public List<DimLocation> getDimLocations() {
		return dimLocations;
	}

	public void setDimLocations(List<DimLocation> dimLocations) {
		this.dimLocations = dimLocations;
	}
}
